<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>取得或设置 apache 请求记录</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="function.apache-lookup-uri.html">« apache_lookup_uri</a></li>
      <li style="float: right;"><a href="function.apache-request-headers.html">apache_request_headers »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="ref.apache.html">Apache 函数</a></li>
    <li>取得或设置 apache 请求记录</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="function.apache-note" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">apache_note</h1>
  <p class="verinfo">(PHP 4, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">apache_note</span> &mdash; <span class="dc-title">取得或设置 apache 请求记录</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.apache-note-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
    <span class="methodname"><strong>apache_note</strong></span>(<span class="methodparam"><span class="type">string</span> <code class="parameter">$note_name</code></span>, <span class="methodparam"><span class="type">?</span><span class="type"><span class="type">string</span><span class="type"></span></span> <code class="parameter">$note_value</code><span class="initializer"> = <strong><code>null</code></strong></span></span>): <span class="type"><span class="type">string</span>|<span class="type"><span class="type false">false</span></span></span></div>

    <p class="para rdfs-comment">
   这个函数是 Apache  <code class="literal">table_get</code> 和
   <code class="literal">table_set</code> 的包装。 
     它编辑了请求中存在的 notes 表。
     这个表的目的是允许 Apache 模块进行通讯。
  </p>
  <p class="para">
   <span class="function"><strong>apache_note()</strong></span> 的主要用途是在同一个请求中，从一个模块传递信息到另一个模块。
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.apache-note-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>
    
     <dt>
<code class="parameter">note_name</code></dt>

     <dd>

      <p class="para">
       note 名。
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">note_value</code></dt>

     <dd>

      <p class="para">
       note 值。
      </p>
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.apache-note-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   如果 <code class="parameter">note_value</code> 被省略或者为 <strong><code>null</code></strong>，则返回记录
   <code class="literal">note_name</code> 的当前值。否则将记录
   <code class="literal">note_name</code> 的值设为
   <code class="literal">note_value</code> 并返回记录
    <code class="literal">note_name</code> 的前一个值。如果未能获取记录，则返回 <strong><code>false</code></strong>。
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.apache-note-changelog">
  <h3 class="title">更新日志</h3>
  <table class="doctable informaltable">
   
    <thead>
     <tr>
      <th>版本</th>
      <th>说明</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
      <td>8.0.0</td>
      <td>
       现在 <code class="parameter">note_value</code> 可为 null。
      </td>
     </tr>

    </tbody>
   
  </table>

 </div>


 <div class="refsect1 examples" id="refsect1-function.apache-note-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-4689">
    <p><strong>示例 #1 在 PHP 与 Perl 之间传递信息</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /><br />apache_note</span><span style="color: #007700">(</span><span style="color: #DD0000">'name'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'Fredrik&nbsp;Ekengren'</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">//&nbsp;调用&nbsp;perl&nbsp;脚本<br /></span><span style="color: #0000BB">virtual</span><span style="color: #007700">(</span><span style="color: #DD0000">"/perl/some_script.pl"</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">$result&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">apache_note</span><span style="color: #007700">(</span><span style="color: #DD0000">"resultdata"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

    <div class="example-contents">
<div class="perlcode"><pre class="perlcode"># 获取 Apache 请求对象
my $r = Apache-&gt;request()-&gt;main();

# 获取传递的数据
my $name = $r-&gt;notes(&#039;name&#039;);

# 一些处理

# 将结果返回给 PHP
$r-&gt;notes(&#039;resultdata&#039;, $result);</pre>
</div>
    </div>

   </div>
  </p>
  <p class="para">
   <div class="example" id="example-4690">
    <p><strong>示例 #2 在 access.log 中记录值</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /><br />apache_note</span><span style="color: #007700">(</span><span style="color: #DD0000">'sessionID'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">session_id</span><span style="color: #007700">());<br /><br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

    <div class="example-contents">
<div class="apachecode"><pre class="apachecode"># &quot;%{sessionID}n&quot; can be used in the LogFormat directive</pre>
</div>
    </div>

   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.apache-note-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="function"><a href="function.virtual.html" class="function" rel="rdfs-seeAlso">virtual()</a> - 执行 Apache 子请求</span></li>
   </ul>
  </p>
 </div>


</div></div></div></body></html>